<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Animal(name){
            this.name = name;
        }
        Animal.prototype.eat = function(what){
            console.log(`${this.name}吃${what}`);
        }
        Animal.prototype.log = function(){
            console.log(this,"111");
        }
        Animal.prototype.weight = "20kg";
        var cat = new Animal("小猫");
        var dog = new Animal("小狗");
        var elephant = Animal("大象");
        cat.eat("鱼");
        dog.eat("骨头");
        cat.__proto__.weight = "10kg";
        console.log(cat);
        console.log(dog);
        Animal.prototype.weight = "100kg";
        console.log(cat,dog);
        cat.log();
        dog.log();
        var arr = [1,2];
        [].__proto__.forEach = function(){
            console.log(this);
        }
        arr.forEach();
        console.log(Animal.prototype);
        console.log(Animal.prototype.__proto__);
        document.body.innerHTML = Animal.toString();
        Animal("狮子");
        console.log(name);
    </script>
</body>
</html>